package com.jueming.cashbook.business.service.impl;

import com.jueming.cashbook.business.mapper.CashTypeMapper;
import com.jueming.cashbook.business.service.CashTypeService;
import com.jueming.cashbook.entity.CashType;
import com.jueming.cashbook.util.SnowFlake;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class CashTypeServiceImpl implements CashTypeService {

    @Autowired
    private CashTypeMapper cashTypeMapper;

    @Override
    public List<CashType> getList() {
        return cashTypeMapper.selectList();
    }

    @Override
    public CashType getById(CashType cashType) {
        return cashTypeMapper.selectById(cashType);
    }

    @Override
    public void add(CashType cashType) {
        cashType.setIsenable(1);
        cashType.setTypeid(String.valueOf(SnowFlake.nextId()));
        cashType.setUpdateId("1");
        cashType.setUpdateTime(new Date());
        cashTypeMapper.insert(cashType);
    }
}
